Delta Lake Fundamentals

How do you create a Delta table from a CSV file?


  • Navigate Unity Catalog using the catalog → schema → volume hierarchy to locate the source CSV file.
  • Confirm the active context with SELECT current_catalog(), current_schema();.
  • Use LIST '/Volumes/<catalog>/<schema>/<volume>/'; to view files in a volume.
  • Preview CSV contents with SELECT * FROM read_files('/Volumes/<catalog>/<schema>/<volume>/<file>.csv', format => 'csv');.
  • Create a Delta table from the CSV using CREATE TABLE <table_name> AS SELECT * FROM read_files('<file_path>', format => 'csv');.
  • Verify the table by querying it in SQL and locating it in Catalog Explorer.

How do you insert, update, and delete records in a Delta table?


  • Use INSERT INTO <table_name> (...) VALUES (...); to add rows.
  • Use UPDATE <table_name> SET <column> = <value> WHERE <condition>; to change existing values.
  • Use DELETE FROM <table_name> WHERE <condition>; to remove matching rows.
  • Include a precise WHERE clause for updates and deletes to avoid modifying unintended rows.
  • Each successful data modification creates a new Delta table version; inspect the change log with DESCRIBE HISTORY <table_name>;.

How do you inspect and query previous versions of a Delta table?


  • Run DESCRIBE HISTORY <table_name>; to view table versions and the operations that produced them.
  • Use SELECT * FROM <table_name> VERSION AS OF 0; to query a specific historical snapshot, such as the original table.
  • Alternatively, use version shorthand such as SELECT * FROM <table_name>@v0;.
  • Compare current and historical results, including row counts, to understand changes; UNION ALL can combine version-specific results for comparison.
  • Time travel helps investigate mistakes and inspect earlier data states, provided the required historical data and transaction logs are still retained.